<template>
  <el-descriptions title="推荐表信息填写确认">
    <el-descriptions-item label="学生">{{ studentObject.name }}({{ studentObject.code }})</el-descriptions-item>
    <el-descriptions-item label="联系方式">{{ studentObject.phoneNumber }}</el-descriptions-item>
    <el-descriptions-item label="qq">{{ studentObject.qq }}</el-descriptions-item>
    <el-descriptions-item label="邮箱">{{ studentObject.email }}</el-descriptions-item>
    <el-descriptions-item label="政治面貌">{{ studentObject.politicalStatus }}</el-descriptions-item>
  </el-descriptions>
  <el-divider/>
  <el-descriptions>
    <el-descriptions-item label="技能证书">{{ studentObject.qualification }}</el-descriptions-item>
    <el-descriptions-item label="计算机等级">{{ studentObject.computerLevel }}</el-descriptions-item>
    <el-descriptions-item label="外语等级">{{ studentObject.foreignLanguageEvel }}</el-descriptions-item>
  </el-descriptions>
  <el-divider/>
  <el-descriptions>
    <el-descriptions-item label="求职意向">{{ studentObject.jobIntention }}</el-descriptions-item>
  </el-descriptions>
  <el-divider/>
  <el-descriptions :column="2">
    <el-descriptions-item label="家庭地址">{{ studentObject.homeAddress }}</el-descriptions-item>
    <el-descriptions-item label="家庭邮编">{{ studentObject.homeCode }}</el-descriptions-item>
    <el-descriptions-item label="家庭联系电话">{{ studentObject.homePhone }}</el-descriptions-item>
    <el-descriptions-item label="城乡生源">
      <el-tag type="">{{ studentObject.isCityStudent == '1' ? "城镇" : "农村" }}</el-tag>
    </el-descriptions-item>
  </el-descriptions>
  <el-divider/>
  <el-descriptions>
    <el-descriptions-item label="户口是否转入学校">
      <el-tag type="">{{ studentObject.isHkInSchool == '1' ? "未转入" : "已转入" }}</el-tag>
    </el-descriptions-item>
    <el-descriptions-item label="入学前户口所在单位">{{ studentObject.rxqhkszdpcs }}</el-descriptions-item>
    <el-descriptions-item label="入学前档案所在单位">{{ studentObject.rxqdaszdw }}</el-descriptions-item>
  </el-descriptions>
  <el-divider/>
  <el-descriptions :column="1">
    <el-descriptions-item label="在校荣誉1">{{ studentObject.rewardPunishmentPrize1 }}</el-descriptions-item>
    <el-descriptions-item label="在校荣誉2">{{ studentObject.rewardPunishmentPrize2 }}</el-descriptions-item>
    <el-descriptions-item label="在校荣誉3">{{ studentObject.rewardPunishmentPrize3 }}</el-descriptions-item>
    <el-descriptions-item label="在校荣誉4">{{ studentObject.rewardPunishmentPrize4 }}</el-descriptions-item>
    <el-descriptions-item label="在校荣誉5">{{ studentObject.rewardPunishmentPrize5 }}</el-descriptions-item>
  </el-descriptions>
  <el-divider/>
  <el-descriptions :column="1">
    <el-descriptions-item label="在校工作或实践经历1">{{ studentObject.workContent1 }}</el-descriptions-item>
    <el-descriptions-item label="在校工作或实践经历2">{{ studentObject.workContent2 }}</el-descriptions-item>
    <el-descriptions-item label="在校工作或实践经历3">{{ studentObject.workContent3 }}</el-descriptions-item>
    <el-descriptions-item label="在校工作或实践经历4">{{ studentObject.workContent4 }}</el-descriptions-item>
    <el-descriptions-item label="在校工作或实践经历5">{{ studentObject.workContent5 }}</el-descriptions-item>
  </el-descriptions>
  <div style="text-align: center;">
    <el-button @click="goBack">我还要修改</el-button>
    <el-button type="primary" @click="goNext" :loading="loading">我已确认</el-button>
  </div>
</template>


<script setup>
import {reactive, ref} from 'vue';
import {EleMessage} from 'ele-admin-plus/es';
import {selectStudentCheckInfo, confirmInfo} from "@/api/student";

const emit = defineEmits(['update:modelValue']);

const props = defineProps({
  modelValue: Number,
});

/** 提交状态 */
const loading = ref(false);


const studentObject = ref({
  code: ''
});


// let studentObject = null;

/** 更新modelValue */
const updateModelValue = (value) => {
  emit('update:modelValue', value);
};


//提交
const goNext = () => {
  let index = props.modelValue;
  loading.value = true;
  confirmInfo()
    .then((msg) => {
      loading.value = false;
      EleMessage.success("操作成功");
      updateModelValue(++index);
    })
    .catch((e) => {
      loading.value = false;
      EleMessage.error(e.message);
    });
}


//返回上一步
const goBack = () => {
  let index = props.modelValue;
  updateModelValue(--index);
}


const selectCheckInfo = () => {
  selectStudentCheckInfo().then(response => {
    console.log(response.data);
    studentObject.value.name = response.data.name;
    studentObject.value.code = response.data.code;

    studentObject.value.phoneNumber = response.data.phoneNumber;
    studentObject.value.politicalStatus = response.data.politicalStatus;
    studentObject.value.qq = response.data.qq;
    studentObject.value.qualification = response.data.qualification;

    studentObject.value.computerLevel = response.data.computerLevel;
    studentObject.value.email = response.data.email;
    studentObject.value.foreignLanguageEvel = response.data.foreignLanguageEvel;
    studentObject.value.homeAddress = response.data.homeAddress;
    studentObject.value.homeCode = response.data.homeCode;
    studentObject.value.homePhone = response.data.homePhone;
    studentObject.value.isCityStudent = response.data.isCityStudent;
    studentObject.value.isHkInSchool = response.data.isHkInSchool;
    studentObject.value.jobIntention = response.data.jobIntention;

    studentObject.value.rewardPunishmentPrize1 = response.data.rewardPunishmentPrize1;
    studentObject.value.rewardPunishmentPrize2 = response.data.rewardPunishmentPrize2;
    studentObject.value.rewardPunishmentPrize3 = response.data.rewardPunishmentPrize3;
    studentObject.value.rewardPunishmentPrize4 = response.data.rewardPunishmentPrize4;
    studentObject.value.rewardPunishmentPrize5 = response.data.rewardPunishmentPrize5;

    studentObject.value.rxqdaszdw = response.data.rxqdaszdw;
    studentObject.value.rxqhkszdpcs = response.data.rxqhkszdpcs;

    studentObject.value.workContent1 = response.data.workContent1;
    studentObject.value.workContent2 = response.data.workContent2;
    studentObject.value.workContent3 = response.data.workContent3;
    studentObject.value.workContent4 = response.data.workContent4;
    studentObject.value.workContent5 = response.data.workContent5;
  })
}


selectCheckInfo();

</script>
